package BSQX_Bit;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class BSQX_4_2 {
    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str= scanner.nextLine();
       // String[] strings=str.split(" ");

        /*这个只是简单的按空格分开来了,但是,双引号问题没有解决
        * 怎么解决双引号?
        * 设立一个标志位,先将双引号的内容,提取出来,然后在用spilt分割*/
        ArrayList<String> arrayList=new ArrayList<>();
        StringBuilder stringBuilder=stringBuilder=new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) != '"' ){
                if (str.charAt(i) != ' ' ){
                    stringBuilder.append(str.charAt(i));
                }else {
                    arrayList.add(stringBuilder.toString());
                    stringBuilder=new StringBuilder();
                }
            }else{
                int j = i+1;
                for (; j < str.length(); j++) {
                    if (str.charAt(j) == '"'){
                        break;
                    }else {
                        stringBuilder.append(str.charAt(j));
                    }
                }
                i=j+1;
                arrayList.add(stringBuilder.toString());
                stringBuilder=new StringBuilder();
            }
        }

        if (stringBuilder.toString().length() != 0){
            arrayList.add(stringBuilder.toString());
        }

        int n= arrayList.size();
        System.out.println(n);
        for (int i = 0; i < n; i++) {
            System.out.println(arrayList.get(i));
        }
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
       int n= scanner.nextInt();
       int m= scanner.nextInt();
       int count=0;
       int per=n;
       while (n <= m){
           int k=func(n,per);
           if (k == -1)break;
           count++;
           per=n;
           n+=k;
       }
       if (n >= m){
           System.out.println(count);
       }else {
           System.out.println(-1);
       }

    }
    public static int func(int a,int b){
        for (int i =b-1; i>1; i--) {
            if (a % i ==0){
                return i;
            }
        }
        return -1;
    }


}
